<script>
	import md5Libs from "uview-ui/libs/function/md5";
	export default {
		onLaunch: async function() {
			// #ifdef H5
			if (window.location.hash != '') {
				let search = window.location.search.substring(1);
				try {
					if (search.indexOf('hashpath') != -1) {
						let sea = JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g,
							'","').replace(/=/g, '":"') + '"}');
						if (sea.hashpath && sea.code && sea.state) {
							window.location.href = window.location.origin + window.location.pathname + '#' + sea
								.hashpath + '?code=' + sea.code + '&state=' + sea.state
						}
					}
				} catch (e) {
					//TODO handle the exception
				}
			}
			// #endif
			//加载配置
			let res = await this.$api.getConfig();

			//主题做缓存
			let theme_key = md5Libs.md5(JSON.stringify(res.data.theme));

			if (!this.vuex_theme.key || this.vuex_theme.key != theme_key) {
				uni.$u.vuex('vuex_theme', {
					key: theme_key,
					value: res.data.theme
				});
			}
			if (!res.code) {
				return;
			}
			uni.$u.vuex('vuex_config', res.data);
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F3F5F8 !important;
	}
	.content {
		padding-top: 88rpx
	}
	.fa-empty{
		margin-top: 100rpx
	}
	/*每个页面公共css */
	@import "uview-ui/index.scss";
</style>